package main

import (
	"io"
	"os"

	"gin/router/user"

	"github.com/gin-gonic/gin"
)

func main() {
	r := gin.Default()
	r.GET("/ping", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"message": "pong",
		})
	})
	// log
	log, err := os.Stat("./log")
	if err != nil {
		println(err.Error())
		errMkdir := os.Mkdir("log", 0777)
		if errMkdir != nil {
			println("create log dictionery error : %S", errMkdir.Error())
		}
	} else {
		println("%S", log.Name())
	}
	gin.DisableConsoleColor()
	f, _ := os.Create("./log/gin.log")
	gin.DefaultWriter = io.MultiWriter(f)
	/////
	user.UserModule(r)
	r.Run() // listen and serve on 0.0.0.0:8080
}
